package com.yricky.memoria.ui.dialog

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDialog
import androidx.compose.foundation.layout.*
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.savedstate.ViewTreeSavedStateRegistryOwner
import com.yricky.memoria.ui.theme.ThemeInst

/**
 * @author Gao-Ruize
 * @date 2021/12/8
 */

fun showConfirmDialog(context: Context, title:String, tip:String, callback:()->Unit){
    showComposeDialog(context){

        Column(
            modifier = Modifier
                .wrapContentHeight()
                .padding(12.dp, 12.dp)
        ){
            Text(
                text = title,
                fontSize = 16.sp,
                modifier = Modifier
                    .padding(8.dp)
            )
            Text(
                text = tip,
                fontSize = 12.sp,
                modifier = Modifier
                    .padding(8.dp, 0.dp)
            )

            Row(
                modifier = Modifier
                    .fillMaxWidth(),
                horizontalArrangement = Arrangement.End
            ) {
                TextButton(
                    onClick = {
                        it.dismiss()
                    }
                ) {
                    Text("取消")
                }
                TextButton(
                    onClick = {
                        callback()
                        it.dismiss()
                    }
                ) {
                    Text("确认")
                }


            }
        }
    }
}
